package com.tx.object.test3;

public class GrilFriend {
    private String name;
    private  int age;
    //private修饰之后只能在该类进行使用
    public void setName(String n){
        name=n;
    }
    public String getName(){
        return name;
    }
    public void setAge(int a){
        if(a>=18&&a<=40){
            age=a;
        }else{
            System.out.println("该数据不合法！");
        }
    }
    public int getAge(){
        return age;
    }


}


